Skip to content

Make Subject required by default in NWBFile::initialize() - #320

Open
oruebel with Copilot wants to merge 42 commits into
add_time_intervalsfrom
copilot/make-subject-required-by-default
Open

Make Subject required by default in NWBFile::initialize()#320
oruebel with Copilot wants to merge 42 commits into
add_time_intervalsfrom
copilot/make-subject-required-by-default

Conversation

Copilot AI commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Fixes #290

nwb-inspector upgraded check_subject_exists to a warning/error for DANDI compliance. AqNWB did not yet support Subject and was silently ignoring this check in CI via --ignore=check_subject_exists.

Changes

  • Added Subject class to represent the /general/subject group in NWB files.
  • Added Subject::SubjectSpec to configure a Subject and facilitate initialization also via NWBFile.
  • Updated nwbinspector tests to remove --ignore=check_subject_exists option to require subject.
  • Updated NWBFile::initialize to accept a SubjectSpec argument for subject metadata initialization

Copilot AI linked an issue Aug 13, 2026 that may be closed by this pull request
Copilot AI and others added 2 commits August 13, 2026 04:58
Co-authored-by: oruebel <10999845+oruebel@users.noreply.github.com>
- Add SubjectMetadata struct to NWBFile.hpp with optional fields for
  species, sex, age, description, subjectId, genotype, strain, weight
- Add subject parameter to NWBFile::initialize() defaulting to an empty
  SubjectMetadata{} (creates a Subject group by default); pass
  std::nullopt to explicitly opt out
- Implement subject group creation in createFileStructure() with
  neurodata_type/namespace attributes for NWB compliance
- Update testNWBFile.cpp to expect Subject in findOwnedTypes results
- Update workflow example to demonstrate Subject usage with actual data
- Remove --ignore=check_subject_exists from tests.yml and
  upgrade_schema.yml CI workflows

Co-authored-by: oruebel <10999845+oruebel@users.noreply.github.com>
Copilot AI changed the title [WIP] Update NWBFile to require subject metadata by default Make Subject required by default in NWBFile::initialize() Aug 13, 2026
Copilot AI requested a review from oruebel August 13, 2026 05:06
@codecov-commenter

codecov-commenter commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.37383% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.52%. Comparing base (c092a77) to head (76be639).

Files with missing lines Patch % Lines
src/nwb/file/Subject.cpp 74.07% 21 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #320      +/-   ##
==========================================
- Coverage   84.69%   84.52%   -0.18%     
==========================================
  Files          57       59       +2     
  Lines        2699     2805     +106     
  Branches      347      371      +24     
==========================================
+ Hits         2286     2371      +85     
- Misses        413      434      +21     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@oruebel
oruebel marked this pull request as ready for review August 13, 2026 08:56
Copilot AI lite review requested due to automatic review settings August 13, 2026 08:56
@oruebel
oruebel requested a review from rly August 13, 2026 09:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds first-class support for the NWB /general/subject group and wires it into NWBFile::initialize() so CI nwbinspector validation no longer needs to ignore the subject-exists check, improving DANDI compliance.

Changes:

  • Added a new NWB::Subject container with a SubjectSpec for initializing subject metadata.
  • Extended NWBFile::initialize() to accept (optional) subject metadata and create /general/subject accordingly.
  • Updated tests, examples, and CI workflows to stop ignoring the subject-exists inspector check.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/testUtils.hpp Adds a shared helper to generate consistent SubjectSpec test metadata.
tests/testSubject.cpp New unit tests covering Subject registration, read/write of fields, and integration with NWBFile::initialize().
tests/testRegisteredType.cpp Adds Subject to the registered type path/name expectations.
tests/testRecordingWorkflow.cpp Updates workflow test to initialize NWBFile with Subject metadata.
tests/testProcessingModule.cpp Updates processing module tests to initialize NWBFile with Subject metadata.
tests/testNWBFile.cpp Updates NWBFile tests for the new initialize signature and Subject default creation expectations.
tests/examples/testWorkflowExamples.cpp Updates example workflow to initialize NWBFile with Subject metadata.
tests/examples/test_link_timeseries_example.cpp Updates link-timeseries example to initialize NWBFile with Subject metadata.
tests/CMakeLists.txt Adds the new testSubject.cpp to the test build.
src/nwb/NWBFile.hpp Extends initialize() API to accept SubjectSpec (via std::optional).
src/nwb/NWBFile.cpp Implements Subject creation during NWBFile initialization.
src/nwb/file/Subject.hpp Introduces the Subject container and SubjectSpec definition and read accessors.
src/nwb/file/Subject.cpp Implements Subject initialization/writing of provided metadata.
CMakeLists.txt Adds Subject.cpp to the library build.
CHANGELOG.md Documents addition of Subject and nwbinspector/initialize updates.
.github/workflows/upgrade_schema.yml Removes ignore of subject-exists; keeps ignore for Allen CCF electrodes location check.
.github/workflows/tests.yml Removes ignore of subject-exists; keeps ignore for Allen CCF electrodes location check.
Suppressed comments (2)

src/nwb/NWBFile.hpp:113

  • The PR title/issue says Subject should be created by default (with an explicit opt-out), but initialize() currently defaults subjectSpec to std::nullopt, so callers who omit the argument still get no /general/subject and will fail nwbinspector unless they remember to pass metadata.
                    const std::string& timestampsReferenceTime = "",
                    const std::optional<AQNWB::NWB::Subject::SubjectSpec>&
                        subjectSpec = std::nullopt);

src/nwb/file/Subject.hpp:78

  • Leftover TODO suggests the initialize method is incomplete, but initialize() is already implemented in Subject.cpp. This looks like generated boilerplate that should be removed to avoid confusion.
  // TODO: Update the initialize method as appropriate.
  /**

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/nwb/NWBFile.cpp
Comment thread src/nwb/file/Subject.hpp Outdated
Comment thread src/nwb/file/Subject.cpp Outdated
Comment thread src/nwb/NWBFile.hpp Outdated
Comment thread src/nwb/file/Subject.cpp
oruebel and others added 2 commits August 13, 2026 02:05
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Comment thread src/nwb/file/Subject.hpp
@oruebel
oruebel changed the base branch from main to schema_2_10 August 20, 2026 19:06
@oruebel oruebel added this to the 0.4.0 milestone Aug 20, 2026
@oruebel oruebel added the category: enhancement proposed enhancements or new features label Aug 20, 2026
@oruebel
oruebel changed the base branch from schema_2_10 to add_time_intervals August 20, 2026 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: enhancement proposed enhancements or new features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make Subject required by default

4 participants